package net.homelinux.ajay.net.ondisk.model.client;

import java.util.HashMap;

public class Folder extends AppObject{

  private HashMap folders = new HashMap();
  private String name;
  private Folder parent;

  public Folder() {
    // Only for serialization purposes
  }
  
  public Folder(String name, Folder folder) {
    this.name = name;
    parent = folder;
    parent.addChild(name, this);
  }

  public void addChild(String name, Folder folder) {
    folders.put(name, folder);
    fireChangeListeners();
  }

  public Folder(String name2) {
    this.name = name2;
  }

  public Folder getFolder(String newFolder) {
    return (Folder) folders.get(newFolder);
  }

  public Folder makeFolder(String name) {
    Folder child = new Folder (name, this);
    return child;
  }

  public void removeFolderFromParent() {
    parent.removeFolder(this.name);
  }

  private Folder removeFolder(String name) {
    return (Folder) folders.remove(name);
  }

  public String getName() {
    return name;
  }

}
